package com.cwiyc.orderonlineback.service;

import com.cwiyc.orderonlineback.common.Result;
import com.cwiyc.orderonlineback.entity.Feedback;
import com.cwiyc.orderonlineback.mapper.FeedbackMapper;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import javax.annotation.Resource;

@Service
public class FeedbackServiceImpl {
    @Resource
    FeedbackMapper feedbackMapper;

    public Result<?> feedb(@RequestBody Feedback feedback) {
        int res = feedbackMapper.tofd(feedback.getMes(), feedback.getUid());
        if (res == 0) {
            return Result.error("-1", "反馈失败");
        }
        int fid = feedbackMapper.getfd();
        String[] sarr = feedback.getImgarray();
        for (int i = 0; i < sarr.length; i++) {
            int ress = feedbackMapper.tofddt(sarr[i],fid);
            if (ress == 0) {
                return Result.error("-1", "存入反馈图片失败");
            }
        }
        return Result.success();
    }
}
